package com.example.testbroadcast;

import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.testbroadcast.reciever.DismissBroadcastReceiver;

public class MyBroadcastActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_broadcast);

        IntentFilter intentFilter=new IntentFilter();
        intentFilter.addAction("dismiss");
        DismissBroadcastReceiver receiver=new DismissBroadcastReceiver();
        registerReceiver(receiver,intentFilter);
        Button btnSendBroadcast= (Button) findViewById(R.id.btn_send_broadcast);
        btnSendBroadcast.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setAction("dismiss");
                sendOrderedBroadcast(intent,null);
            }
        });

    }
}
